home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1999 February / EnigmA AMIGA RUN 34 (1999)(G.R. Edizioni)(IT)[!][issue 1999-02].iso / www / amitrix / awebdl.lha / AWebDL.awebrx next >
Text File  |  1998-01-27  |  2KB  |  115 lines

  1. /*
  2.     $VER: AWebDL 2.1 (15.12.97) by Gabriele Favrin (favrin@tin.it)
  3.     Download script for AWeb 3.0+
  4.  
  5.     See documentation for informations!
  6. */
  7.  
  8. options results
  9.  
  10. log = ""
  11. url = ""
  12. req = 0
  13.  
  14. savedir    = ""
  15. eol        = '0A'x
  16. append    = ""
  17. chars        = '`~"=#?/:;\*%()[]<>'||"'"
  18.  
  19. parse ARG args
  20.  
  21. interpret translate(strip(args), ';',' ')
  22. savedir=translate(savedir, ' ', ';')
  23.  
  24. If Right(savedir, 1) ~= "/" & Right(savedir, 1) ~= ":" then do
  25.     savedir=savedir"/"
  26. end
  27.  
  28. file=Translate(url,,chars)
  29. file=savedir||Word(file, Words(file))
  30.  
  31. If Exists(file) then do
  32.     If req == 1 then do
  33.         Call ShowReq()
  34.     end
  35.     else do
  36.         Call AutoName()
  37.     end
  38. end
  39.  
  40. 'LOAD "'url'" SAVEAS "'file'"' append
  41.  
  42. If log ~= "" then do
  43.     call SaveLog()
  44. end
  45.  
  46. exit 0
  47.  
  48.  
  49. AutoName:
  50.     num = 2
  51.  
  52.     do while Exists(file||'.'num)
  53.         num=num+1
  54.     end
  55.     file=file||'.'||num
  56.     return
  57.  
  58.  
  59. SaveLog:
  60.     log=translate(log, ' ', ';')
  61.  
  62.     If exists(log) then do
  63.         wflag="A"
  64.     end
  65.     else do
  66.         wflag="W"
  67.     end
  68.  
  69.     If Open(fh, log, wflag) then do
  70.         Call WriteCH(fh, 'File: 'file||eol||'URL : 'translate(url, ' ', ';')||eol||'Date: 'date()", "time()||eol||eol)
  71.         Call Close(fh)
  72.     end
  73.     return
  74.  
  75.  
  76. ShowReq:
  77.     flag=0
  78.  
  79.     do while flag == 0
  80.         'Request "AWebDL" "File:*N'file'*NAlready exists!" "_Overwrite|_Append|Auto _rename|_New name|_Cancel"'
  81.  
  82.         If rc == 5 then do
  83.             exit 0
  84.         end
  85.         else do
  86.             select
  87.                 when result == 1 then flag=1
  88.                 when result == 2 then do
  89.                     drop append
  90.                     flag=1
  91.                 end
  92.  
  93.                 when result == 3 then do
  94.                     Call AutoName()
  95.                     flag=1
  96.                 end
  97.  
  98.                 when result == 4 then do
  99.                     'RequestFile "AWebDL - select new file name" FILE 'file' SAVEMODE'
  100.                     If rc == 5 then do
  101.                         exit 0
  102.                     end
  103.                     else do
  104.                         If ~exists(result) then do
  105.                             file=result
  106.                             flag=1
  107.                         end
  108.                     end
  109.                 end
  110.                 otherwise nop
  111.             end
  112.         end
  113.     end
  114.     return
  115.